<?php
/*
	Copyright 2010 Ping Shin Ching (ping_sc@hotmail.com)

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

		http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
 */


include 'supercaptcha.php';

if(strcasecmp($_SERVER['REQUEST_METHOD'], "POST")!=0){
?>
<html><head><title>Bot or Human</title>
<link rel="stylesheet" type="text/css" href="in_style.css"/>
<script type="text/javascript">
var RecaptchaOptions = {
	theme : 'clean'
};
</script>
</head><body>
<center>
<br/><br/>
<table class="bodytable"><tr><td>
	<h1>Captcha</h1>
	This proxy needs to find out if you are human. The reason being that this is a proxy for human surfing and not for Bots.
	Also, this author takes a dim view of spam from bots.<br/><br/>
	<form method="post" action="in_checkifhuman.php">
	<?php
		require_once('recaptchalib.php');
		echo recaptcha_get_html($publickey);
		echo "<input type=\"hidden\" name=\"refering_site\" value=\"".$_GET["url"]."\"/>";
	?>
	<input type="submit" />
	</form>
	</td></tr></table>
</center>    
</body>
</html>
<?php
}
else{
	require_once('recaptchalib.php');
	$resp = recaptcha_check_answer ($privatekey,
                                $outgoingip,
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

	if (!$resp->is_valid) {
		header("Location: ".$_POST['refering_site']);
  	} 
	else {
		iamhuman($_SERVER['REMOTE_ADDR']);
		header("Location: ".$_POST['refering_site']);
	}
}
 ?>
